import React from 'react'
import { Router, Route } from 'dva/router'
import auth from './services/auth'
import { LocaleProvider } from 'antd'
import en_US from 'antd/lib/locale-provider/en_US'
import 'moment/locale/zh-cn'

import HomePage from './components/homePage/Index'

// ================================================login
import Login from './components/login/Login'

// ============================================MainLayout
import MainLayout from './components/layout/MainLayout'

// ==========================================admin
import MenuAdd from './components/admin/menu/Add'
import MenuList from './components/admin/menu/Index'
import AdminList from './components/admin/admin/Index'
import AddAdminRole from './components/admin/role/Edit'
import AdminRoleList from './components/admin/role/Index'
import AdminEdit from './components/admin/admin/Edit'
import Config from './components/admin/config/Index'
import BusinessConfig from './components/admin/bsConfig/Index'
import SecuritySettings from './components/admin/admin/SecuritySettings'

// ===========================================finance
import CheckTotal from './components/finance/checkTotal/Index'
import Apply from './components/finance/apply/Index'
import InitialOrderNew from './components/finance/initialOrder/New'
import InitialOrderRepeat from './components/finance/initialOrder/Repeat'
import InitialOrderReupload from './components/finance/initialOrder/Reupload'
import TelOrderNew from './components/finance/telOrder/New'
import TelOrderRepeat from './components/finance/telOrder/Repeat'
import PhotoCheckNew from './components/finance/photoCheck/New'
import PhotoCheckOld from './components/finance/photoCheck/Old'
import RiskWaiting from './components/finance/photoCheck/RiskWaiting'
import RiskWaitingRepeat from './components/finance/photoCheck/RiskWaitingRepeat'
import PhotoCheckNewUn from './components/finance/photoCheck/NewUnconnected'
import SecondNew from './components/finance/photoCheck/SecondNew'
import SecondRepeat from './components/finance/photoCheck/SecondRepeat'
import PhotoCheckRepeat from './components/finance/photoCheck/Repeat'
import PhotoCheckReupload from './components/finance/photoCheck/Reupload'
import PassOrder from './components/finance/OrderView/PassOrder'
import RefuseOrder from './components/finance/OrderView/RefuseOrder'
import ReeditOrder from './components/finance/OrderView/ReeditOrder'
import UnAssignedOrder from './components/finance/OrderView/UnAssignedOrder'
import FinalNew from './components/finance/finalireview/New'
import FinalOld from './components/finance/finalireview/Repeat'
import CallsStatistics from './components/finance/callsStatistics/Index'
import Common from './components/common/components/stats/stats'
import DataQuery from './components/common/components/stats/StatsV2'
import SingleDateDataQuery from './components/common/components/stats/SingleDateStats'
import Distribution from './components/finance/distribution/Index'
import AuditorList from './components/finance/auditor/Index'
import AgentManage from './components/overdue/agent/Index'
import CallRecords from './components/overdue/callDuration/Index'
import FollowRecords from './components/overdue/followRecords/Index'

// ===========================================overdue
import OverdueList from './components/overdue/allocationOrder/Index'
import ExternalOverdueCheck from './components/overdue/externalOverdueCheck/Index'
import PersonalCheckList from './components/overdue/personalCheckList/Index'
import SheildPhone from './components/overdue/sheildPhone/sheildPhone'
import CollectionAssessment from './components/overdue/efficiencyStatistics/Index'
import OverdueTransfer from './components/overdue/overdueTransfer/index'
import ManualAssign from './components/overdue/manualAssign/Index'
import Outbound from './components/overdue/outbound/Index'
import UniqueExtStats from './components/dataReport/UniqueExtStats'

// ===================================== user
import UserManage from './components/users/manage/Index'
import UserPromotion from './components/users/promotion-data-entry/components/index'
import UserThaw from './components/users/thaw/Thaw'
import feedBack from './components/users/feedback'
import Assessment from './components/users/report/assessment'

// =============================================affairs
import Paid from './components/affairs/paid/Index'
import PaidNoOperation from './components/affairs/paid/IndexNoOperation'
import EnterAccount from './components/affairs/enterAccount/Index'
import PayBack from './components/affairs/payBack/Index'
import FundConfirm from './components/affairs/fundConfirm/Index'
import FundPool from './components/affairs/fundPool/Index'
import FundAccounting from './components/affairs/fundAccounting/Index'
import CapitalClear from './components/affairs/capitalClear/Index'
import HandInput from './components/affairs/handInput/Index'
import InputRecord from './components/affairs/inputRecord/Index'
import LineCapitalList from './components/affairs/lineCapitalList/Index'
import TransferCompletedList from './components/affairs/transfer/Index'
import PaymentCenter from './components/affairs/paymentCenter/index'
import AccountList from './components/affairs/accountList/Index'
import Account from './components/affairs/account/Index'
import DailyBalance from './components/affairs/dailyBalance/Index'
import ServiceFee from './components/affairs/ServiceFee/Index'
import DownloadReports from './components/affairs/downloadReports/Index'
import EnterAccountList from './components/affairs/enterAccountList/Index'
import ExceptionList from './components/affairs/exceptionList/Index'
import Statement from './components/overdue/statement/Index'
import UserBlackList from './components/overdue/blackList/Index'
import CollectionCase from './components/overdue/case/internalCollection/CollectionCase'
import ClPaidList from './components/overdue/paidlist/Index'
import ServiceCharge from './components/affairs/serviceCharge/Index'

// =================================================operation(运营)
import BannerAdd from './components/operation/banner/Add'
import BannerList from './components/operation/banner/Index'
import ActivityList from './components/operation/activity/Index'
import PushList from './components/operation/push/List'
import HotspotList from './components/operation/hotspot/Index'
import HotContent from './components/operation/hotspot/hotContent/Index'
import SmsMessage from './components/operation/smsmessage/List'
import MessageSearch from './components/operation/message/searchmsg'
import MessageApp from './components/operation/message/app'
import MessageBiz from './components/operation/message/biz'
import MessageList from './components/operation/message/messageList'
import MessageServicer from './components/operation/message/servicer'
import MessageTemplate from './components/operation/message/template'
import SendOperationMsg from './components/operation/message/sendMessage'
import MessageRule from './components/operation/message/rule'
import CouponTemplate from './components/operation/coupon/List'
import ProductList from './components/operation/product/Index'

// =============================================== data report
import auditData from './components/dataReport/auditData/Index'
import registerData from './components/dataReport/Register'
import apply from './components/dataReport/Apply'
import loan from './components/dataReport/Loan'
import commonStats from './components/dataReport/Common'
import CommonAgentDayStats from './components/dataReport/CommonAgentDayStats'
import CommonApply from './components/dataReport/CommonApply'
import CommonDisburse from './components/dataReport/CommonDisburse'
import CommonRepayment from './components/dataReport/CommonRepayment'
import CommonActuralRepayment from './components/dataReport/CommonActuralRepayment'
import riskRules from './components/dataReport/RiskRules'
import income from './components/dataReport/Income'
import riskFees from './components/dataReport/RiskFees'
import riskGrades from './components/dataReport/RiskGrades'
import repayment from './components/dataReport/Repayment'
import collectionRepaymentDateBased from './components/dataReport/CollectionRepaymentDateBased'
import agentDaysStats from './components/dataReport/AgentDaysStats'
import merchantInit from './components/dataReport/MerchantInit'
import supposeRepaymentUshaBeauty from './components/dataReport/RepaymentUshaBeauty'
import supposeRepayment from './components/dataReport/SupposeRepayment'
import repaymentChannel from './components/dataReport/RepaymentChannel'
import profit from './components/dataReport/Profit'
import loanUsha from './components/dataReport/LoanUshaBeauty'
import CuiShouMian from './components/dataReport/CuiShouMian'
import AppDataCollecting from './components/dataReport/AppDataCollecting'
import AuditConvert from './components/dataReport/AuditConvert'
import ClRecordDtl from './components/dataReport/ClRecordDtl'
import ClRecordStat from './components/dataReport/ClRecordStat'
import ClRecordCount from './components/dataReport/ClRecordCount'
import PaidDateStat from './components/dataReport/PaidDateStat'
import NoRepayStat from './components/dataReport/NoRepayStat'

// =============================================== merchant（商户）
import MerchantDashboard from './components/merchant/Dashboard'
import UniqueStats from './components/dataReport/UniqueStats'
import allStats from './components/overdue/stats/AllStats'
import allStatsGroup from './components/overdue/stats/AllStatsGroup'

const requireAuth = (nextState, replace) => {
  if (!auth.loggedIn()) {
    replace({
      pathname: '/login',
      state: { nextPathname: nextState.location.pathname }
    })
  }
}

export default function ({ history }) {
  return (
    <LocaleProvider locale={en_US}>
      <Router history={history}>

        <Route path='/login' component={Login}/>
        <Route path='/homePage' component={HomePage}/>

        <Route path='/' component={MainLayout} onEnter={requireAuth}>
          /*权限*/
          <Route path='/admin'>
            <Route path='menu/add' component={MenuAdd}/>
            <Route path='menu/list' component={MenuList}/>
            <Route path='list' component={AdminList}/>
            <Route path='add' component={AdminEdit}/>
            <Route path='edit/:id' component={AdminEdit}/>
            <Route path='role/add' component={AddAdminRole}/>
            <Route path='role/edit/:id' component={AddAdminRole}/>
            <Route path='role/list' component={AdminRoleList}/>
            <Route path='config' component={Config}/>
            <Route path='businessConfig/:businessKey' component={BusinessConfig}/>
            <Route path='security' component={SecuritySettings}/>
          </Route>

          /*信审*/
          <Route path='/finance'>
            <Route path='initialOrder/new' component={InitialOrderNew}/>
            <Route path='initialOrder/repeat' component={InitialOrderRepeat}/>
            <Route path='initialOrder/reupload' component={InitialOrderReupload}/>
            <Route path='telOrder/new' component={TelOrderNew}/>
            <Route path='telOrder/repeat' component={TelOrderRepeat}/>
            <Route path='photoCheck/new' component={PhotoCheckNew}/>
            <Route path='photoCheck/old' component={PhotoCheckOld}/>
            <Route path='riskwaiting/new' component={RiskWaiting}/>
            <Route path='riskwaiting/repeat' component={RiskWaitingRepeat}/>
            <Route path='photoCheck/secondNew' component={SecondNew}/>
            <Route path='photoCheck/secondRepeat' component={SecondRepeat}/>
            <Route path='photoCheck/newUnconnected' component={PhotoCheckNewUn}/>
            <Route path='photoCheck/repeat' component={PhotoCheckRepeat}/>
            <Route path='photoCheck/reupload' component={PhotoCheckReupload}/>
            <Route path='passOrder/index' component={PassOrder}/>
            <Route path='refuseOrder/index' component={RefuseOrder}/>
            <Route path='reeditOrder/index' component={ReeditOrder}/>
            <Route path='unassignedOrder/index' component={UnAssignedOrder}/>
            <Route path='check_total/index' component={CheckTotal}/>
            <Route path='apply/index' component={Apply}/>
            <Route path='finalreviewNew/index' component={FinalNew}/>
            <Route path='finalreviewOld/index' component={FinalOld}/>
            <Route path='assessment' component={Assessment}/>
            <Route path='callsStatistics' component={CallsStatistics}/>
            <Route path='distribution/index' component={Distribution}/>
            <Route path='auditor/manage' component={AuditorList}/>
          </Route>

          /*催收管理*/
          <Route path='/overdue'>
            <Route path='externalOverdueCheck' component={ExternalOverdueCheck}/>
            <Route path='overduelist' component={OverdueList}/>
            {/*催收页面四合一*/}
            <Route path='case/dashboard' components={CollectionCase}/>
            <Route path='paidList' components={ClPaidList}/>
            <Route path='personalCheck' component={PersonalCheckList}/>
            <Route path='urgentSwitch' component={SheildPhone}/>
            <Route path='statement' component={Statement}/>
            <Route path='userBlackList' component={UserBlackList}/>
            <Route path='assessment' component={CollectionAssessment}/>
            <Route path='overdueTransfer' component={OverdueTransfer}/>
            <Route path='uniqueStats' component={UniqueStats}/>
            <Route path='uniqueExtStats' component={UniqueExtStats}/>
            <Route path='allStats' component={allStats}/>
            <Route path='allStatsGroup' component={allStatsGroup}/>
            <Route path='manualAssign' component={ManualAssign}/>
            <Route path='agent/manage' component={AgentManage}/>
            <Route path='outbound' component={Outbound}/>
            <Route path='call/records' component={CallRecords}/>
            <Route path='follow/records' component={FollowRecords}/>
          </Route>

          /*用户管理*/
          <Route path='/users'>
            <Route path='manage' component={UserManage}/>
            <Route path='promotion' component={UserPromotion}/>
            <Route path='thaw' component={UserThaw}/>
            <Route path='thaw' component={UserThaw}/>
            <Route path='feedback' component={feedBack}/>
          </Route>

          /*财务*/
          <Route path='/affairs'>
            <Route path='paid' component={Paid}/>
            <Route path='waitRepay' component={PaidNoOperation}/>
            <Route path='fund_confirm' component={FundConfirm}/>
            <Route path='fund_pool' component={FundPool}/>
            <Route path='fund_Accounting' component={FundAccounting}/>
            <Route path='repayment_list' component={PayBack}/>
            <Route path='booking_list' component={EnterAccount}/>
            <Route path='capitalClear' component={CapitalClear}/>
            <Route path='handInput' component={HandInput}/>
            <Route path='inputRecord' component={InputRecord}/>
            <Route path='lineCapitalList' component={LineCapitalList}/>
            <Route path='transferConfirmationList' component={TransferCompletedList}/>
            <Route path='paymentCenter' component={PaymentCenter}/>
            <Route path='accountList' component={AccountList}/>
            <Route path='account' component={Account}/>
            <Route path='dailyBalance' component={DailyBalance}/>
            <Route path='servicefee' component={ServiceFee}/>
            <Route path='downloadReports' component={DownloadReports}/>
            <Route path='enterAccountList' component={EnterAccountList}/>
            <Route path='exceptionList' component={ExceptionList}/>
            <Route path='serviceCharge' component={ServiceCharge}/>
            {/* <Route path='transfer_sign' component={TransferSign}/> */}
          </Route>
          /*运营*/
          <Route path='/operation'>
            <Route path='hotspot/list' component={HotspotList}/>
            <Route path='hotspot/add' component={HotContent}/>
            <Route path='hotspot/edit' component={HotContent}/>
            <Route path='banner/add' component={BannerAdd}/>
            <Route path='banner/list' component={BannerList}/>
            <Route path='activity/list' component={ActivityList}/>
            <Route path='push/list' component={PushList}/>
            <Route path='smsmessage/list' component={SmsMessage}/>
            <Route path='message/search' component={MessageSearch}/>
            <Route path='message/app' component={MessageApp}/>
            <Route path='message/biz' component={MessageBiz}/>
            <Route path='message/servicer' component={MessageServicer}/>
            <Route path='message/template' component={MessageTemplate}/>
            <Route path='message/messageList' component={MessageList}/>
            <Route path='message/sendMessage' component={SendOperationMsg}/>
            <Route path='message/rule' component={MessageRule}/>
            <Route path='coupon/list' component={CouponTemplate}/>
            <Route path='coupon/list' component={CouponTemplate}/>
            <Route path='product/list' component={ProductList}/>
          </Route>


          /*用户管理*/
          <Route path='/data'>
            <Route path='audit' component={auditData}/>
          </Route>


          /*报表管理*/
          <Route path='/DR'>
            <Route path='common/:statsKey' component={commonStats}/>
            <Route path='common/agentDailyStats2/:statsKey' component={CommonAgentDayStats}/>
            <Route path='common/register/:statsKey' component={commonStats}/>
            <Route path='common/apply/:statsKey' component={CommonApply}/>
            <Route path='common/disburse/:statsKey' component={CommonDisburse}/>
            <Route path='common/repayment/:statsKey' component={CommonRepayment}/>
            <Route path='common/acturalRepayment/:statsKey' component={CommonActuralRepayment}/>
            <Route path='common/:statsKey' component={commonStats}/>
            <Route path='dateQuery/:statsKey' component={Common}/>
            <Route path='bizDataQuery/:queryKey' component={DataQuery}/>
            <Route path='singleDateQuery/:queryKey' component={SingleDateDataQuery}/>
            <Route path='register' component={registerData}/>
            <Route path='apply' component={apply}/>
            <Route path='loan' component={loan}/>
            <Route path='income' component={income}/>
            <Route path='riskRules' component={riskRules}/>
            <Route path='riskGrades' component={riskGrades}/>
            <Route path='riskFees' component={riskFees}/>
            <Route path='repayment' component={repayment}/>
            <Route path='collectionRepaymentDateBased' component={collectionRepaymentDateBased}/>
            <Route path='agentDaysStats' component={agentDaysStats}/>
            <Route path='merchantInit' component={merchantInit}/>
            <Route path='supposeRepayment' component={supposeRepayment}/>
            <Route path='repaymentChannel' component={repaymentChannel}/>
            <Route path='profit' component={profit}/>
            <Route path='suppose-repayment-usa-beauty' component={supposeRepaymentUshaBeauty}/>
            <Route path='disbursement-usha-beauty' component={loanUsha}/>
            <Route path='cuishoumian' component={CuiShouMian}/>
            <Route path='appDataCollecting' component={AppDataCollecting}/>
            <Route path='auditConvert' component={AuditConvert}/>
            <Route path='clRecordDtl' component={ClRecordDtl}/>
            <Route path='clRecordStat' component={ClRecordStat}/>
            <Route path='clRecordCount' component={ClRecordCount}/>
            <Route path='paidDateStat' component={PaidDateStat}/>
            <Route path='noRepayStat' component={NoRepayStat}/>
          </Route>

          /*商户后台*/
          <Route path='/merchant'>
            <Route path='dashboard' components={MerchantDashboard}/>
          </Route>
        </Route>
      </Router>
    </LocaleProvider>
  )
};
